<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
<!-- creator-mime-types.qdoc -->
  <title>Editing MIME Types | Qt Creator Manual</title>
  <link rel="stylesheet" type="text/css" href="style/offline-simple.css" />
  <script type="text/javascript">
    document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css");
    // loading style sheet breaks anchors that were jumped to before
    // so force jumping to anchor again
    setTimeout(function() {
        var anchor = location.hash;
        // need to jump to different anchor first (e.g. none)
        location.hash = "#";
        setTimeout(function() {
            location.hash = anchor;
        }, 0);
    }, 0);
  </script>
</head>
<body>
<div class="header" id="qtdocheader">
  <div class="main">
    <div class="main-rounded">
      <div class="navigationbar">
        <table><tr>
<td ><a href="index.html">Qt Creator Manual</a></td><td >Editing MIME Types</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right"><a href="index.html">Qt Creator Manual 4.11.1</a></td>
        </tr></table>
      </div>
    </div>
<div class="content">
<div class="line">
<div class="content mainContent">
  <link rel="prev" href="creator-language-servers.html" />
  <link rel="next" href="creator-modeling.html" />
<p class="naviNextPrevious headerNavi">
<a class="prevPage" href="creator-language-servers.html">Using Language Servers</a>
<span class="naviSeparator">  &#9702;  </span>
<a class="nextPage" href="creator-modeling.html">Modeling</a>
</p><p/>
<div class="sidebar"><div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">Editing MIME Types</h1>
<span class="subtitle"></span>
<!-- $$$creator-mime-types.html-description -->
<div class="descr"> <a name="details"></a>
<p>Qt Creator uses the <a href="https://www.iana.org/assignments/media-types/media-types.xhtml">MIME type</a> of the file to determine which mode and editor to use for opening the file. For example, Qt Creator opens C++ source and header files in the C++ editor, and Qt widget based UI files (.ui) in Qt Designer. For some MIME types, you can change the editor that is used to open the files of that type by default.</p>
<p>To identify the MIME type of a file, Qt Creator uses matching by pattern and matching by contents. First, Qt Creator looks at the filename to check whether it matches the patterns specified for any MIME type. If no match is found, it checks the contents of the file for magic headers specified for the file.</p>
<p>The magic headers can contain the following types of values: string, host, big-endian, little-endian, and byte. Qt Creator interprets the values according to the <a href="http://standards.freedesktop.org/shared-mime-info-spec/shared-mime-info-spec-latest.html">Shared MIME-info Database specification</a>.</p>
<p>Qt Creator searches for the value within a specified range in the files and takes the priority of the magic header into account. If you specify wide search ranges, openging files in Qt Creator might take a long time. Therefore, you are advised to use the recommended values for the range and priority of the magic header.</p>
<p>If your files do not match the predefined MIME types, you can edit the MIME types to add filename extensions and magic headers. You cannot add new MIME types, however.</p>
<p>To edit MIME types:</p>
<ol class="1" type="1"><li>Select <b>Tools &gt; Options &gt; Environment &gt; MIME Types</b>.<p class="centerAlign"><img src="images/qtcreator-mime-types.png" alt="&quot;MIME Types&quot;" /></p></li>
<li>In <b>MIME Type</b>, select a MIME type.</li>
<li>In <b>Patterns</b>, add the filename extension for the type of files that you want to identify as having this MIME type.</li>
<li>Click <b>Add</b> to add <b>Magic Headers</b>.<p class="centerAlign"><img src="images/qtcreator-mime-types-magic-header.png" alt="&quot;Magic Header&quot;" /></p></li>
<li>In the <b>Value</b> field, specify a text string or bytes that appear in the files.</li>
<li>In the <b>Type</b> field, select the type of the value.</li>
<li>In the <b>Mask</b> field, specify the number to combine the value in the file with using the AND operator before comparing it to the specified value. You can specify any numbers as masks for numerical types, whereas masks for strings must be in base 16, and start with 0x.<p><b>Note: </b>You are recommended not to change the range and priority, because it might cause problems when opening files in Qt Creator.</p></li>
<li>In <b>Handler</b>, double-click the editor name to display a context-menu where you can select another editor to open the file in by default. The menu is available only if alternative suitable editors are available.</li>
<li>Click <b>OK</b>.</li>
</ol>
<p>Even if an alternative editor is not listed for a MIME type, you can still change the editor that is used to open the files of a particular type. Remove the filename extension from the current MIME type and add it to a MIME type that is handled by the editor you want to use. For example, to edit Linux kernel device tree source (.dts) files with the text editor, delete the pattern <code>*.dts</code> from the MIME type <code>audio/vnd.dts</code> (where it represents the digital surround audio file format), and add it to the <code>text/plain</code> MIME type. You can use the <b>Filter</b> field to find the MIME type that currently contains a filename extension.</p>
<p>To revert the changes you have made to the MIME type definitions, select <b>Reset MIME Types</b>. To revert the changes you have made to the default editors, select <b>Reset Handlers</b>.</p>
<p><b>Note: </b>If you now select <b>OK</b> or <b>Apply</b>, you permanently lose all your own patterns and magic headers. The changes are reverted the next time you start Qt Creator.</p></div>
<!-- @@@creator-mime-types.html -->
<p class="naviNextPrevious footerNavi">
<a class="prevPage" href="creator-language-servers.html">Using Language Servers</a>
<span class="naviSeparator">  &#9702;  </span>
<a class="nextPage" href="creator-modeling.html">Modeling</a>
</p>
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</acronym> 2019 The Qt Company Ltd.
   Documentation contributions included herein are the copyrights of
   their respective owners.<br>    The documentation provided herein is licensed under the terms of the    <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation    License version 1.3</a> as published by the Free Software Foundation.<br>    Qt and respective logos are trademarks of The Qt Company Ltd.     in Finland and/or other countries worldwide. All other trademarks are property
   of their respective owners. </p>
</div>
</body>
</html>
